package com.hzsoft.base.entity;

import java.io.Serializable;

public class Page implements Serializable{
	
	
	private int totalPage; // 总页数
	private int total; // 总记录数
	private int pageSize;//页大小(每页记录数)。//numPerPage dwz<!--前台动态设置每页显示多少条-->
	private int pageCurrent;//当前页。
	private int pageNum;//显示的数字页码个数。pageNum
	private boolean entityOrField; // true:需要分页的地方，传入的参数就是Page实体；false:需要分页的地方，传入的参数所代表的实体拥有Page属性
	private int currentResult; // 当前记录起始索引
	
	public int getTotalPage() {
		
		if (total % getPageSize() == 0)
			totalPage = total / getPageSize();
		else
			totalPage = total / getPageSize() + 1;
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getCurrentResult() {
		
		currentResult = (getPageCurrent() - 1) * getPageSize();
		if (currentResult < 0)
			currentResult = 0;
		
		return currentResult;
	}

	public void setCurrentResult(int currentResult) {
		this.currentResult = currentResult;
	}

	public int getPageSize() {
		
		if (pageSize == 0) {
			pageSize = 10;
		}
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageCurrent() {
		if (pageCurrent <= 0)
			pageCurrent = 1;
		if (pageCurrent > getTotalPage())
			
			pageCurrent = getTotalPage();
		return pageCurrent;
	}

	public void setPageCurrent(int pageCurrent) {
		this.pageCurrent = pageCurrent;
	}

	public int getPageNum() {
		if (pageNum == 0) {
			pageNum = 5;
		}
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public boolean isEntityOrField() {
		return entityOrField;
	}

	public void setEntityOrField(boolean entityOrField) {
		this.entityOrField = entityOrField;
	}

}
